package entity.props;

import com.hzheima.util.ImageUtil;
import constant.UiConstant;
import entity.FlyingObject;

import java.util.ArrayList;
import java.util.Random;

/**
 * @Author: hjh
 * @Date: 2025/09/09 20:00
 * @Description: 血包
 */
public class HealthPack extends FlyingObject {
    public int healing;
    private Random random = new Random();
    public static int count = 0;
    public static ArrayList<HealthPack> healthPacks = new ArrayList<>();

    public HealthPack() {
        image = ImageUtil.getImg("blood.png");
        x = random.nextInt(UiConstant.APP_WIDTH - width);
        y = - height;
        width = image.getWidth()/6;
        height = image.getHeight()/6;
        healing = 1;
        ySpeed = 5;
    }

    public void move(){
        y += ySpeed;
    }

    public static void createHealthPack(){
        HealthPack.count++;
        if (HealthPack.count % 50 == 0 && healthPacks.isEmpty()){
           healthPacks.add(new HealthPack());
           HealthPack.count = 0;
        }
    }

    //小球移动
    public static void HealthPackMove() {

        for (int i = healthPacks.size() - 1; i >= 0; i--) {
            healthPacks.get(i).move();
            if (healthPacks.get(i).y >= UiConstant.APP_HEIGHT) {
                healthPacks.remove(healthPacks.get(i));
            }
        }

    }
}
